home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 010a / cliptree.zip / MISC.PRG < prev    next >
Text File  |  1993-02-08  |  6KB  |  181 lines

  1. /*┌──────────────────────────────────────────────────────────────────────┐
  2.  ▌│                                                                      │
  3.  ▌│ Program Name: MISC.PRG           Purpose.: Various functions         │
  4.  ▌│ Date Created: 02/06/93           Language: Clipper 5.0               │
  5.  ▌│ Time Created: 10:56:24             Author: Kevin S Gallagher         │
  6.  ▌│ PickOne() by: Stephen L. Woolstenhulme                               │
  7.  ▌│                                                                      │
  8.  ▌│                                                                      │ 
  9.  ▌└──────────────────────────────────────────────────────────────────────┘
  10.  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀           */
  11.  
  12. #include "include1.h"
  13.   
  14. function BoxShad( nTR, nTC, nBR, nBC, cClrs,nShad )
  15.     local ShadColor := IF( VALTYPE( nShad ) == "N", CHR(nShad), CHR(8) )
  16.     EVAL(                                                              ;
  17.     { | cDefCol | cDefCol:=SETCOLOR( cClrs ),                          ;
  18.     RESTSCREEN( nTR+1, nTC+2, nBR+1, nBC+2,                            ;
  19.     TRANSFORM( SAVESCREEN( nTR+1, nTC+2, nBR+1, nBC+2 ),               ;
  20.     REPLICATE( "X"+ShadColor, ( nBR-nTR+1 ) * ( nBC-nTC+1 ) ) ) ),     ;
  21.     DISPBOX( nTR, nTC, nBR, nBC,"╔═╗║╝═╚║ "),                          ;
  22.     SETCOLOR( cDefCol ) }                                              )
  23. return nil
  24. /*
  25. * Author: Stephen L. Woolstenhulme
  26. */
  27. function PickOne( cText, aPicks, nRow, nWhich, cColor )
  28.    local nOffSet, nArrayLen, nSpace, nLcol, cScrn, nLen, i
  29.    local getlist := {}
  30.    memvar gcBoxColor
  31.    nOffSet  := len( cText ) / 2 + 2
  32.    nArrayLen:= 0
  33.    nRow     := IF( nRow   == Nil, 21, nRow )
  34.    nWhich   := IF( nWhich == Nil,  1, nWhich )
  35.  
  36.    if cColor == Nil
  37.        if type( 'gcBoxColor' ) == 'C'
  38.            cColor := gcBoxColor
  39.        else
  40.            cColor := 'w+/r, n/w ,,, w+/n'
  41.        endif
  42.    endif
  43.  
  44.    nRow := IF( nRow > maxcol() - 1, maxcol() - 1, nRow )
  45.    nRow := IF( nRow < 2, 2, nRow )
  46.    nLen := len( aPicks )
  47.  
  48.    FOR i := 1 TO nLen
  49.       nArrayLen += len( aPicks[ i ] )
  50.    NEXT
  51.  
  52.    if nArrayLen + len( aPicks ) - 1 >= len( cText )
  53.       nSpace := 2
  54.    else
  55.       nSpace :=  ( len( cText ) - nArrayLen ) / ( len( aPicks ) + 1 )
  56.    endif
  57.  
  58.    nLcol  := ( maxcol() / 2 + 1 ) - ;
  59.              ( max( len( cText ), nArrayLen + nSpace * len( aPicks ) ) / 2 )
  60.    cScrn  := savescreen( nRow - 3, 0, nRow + 3, maxcol() )
  61.    cColor := SetColor( cColor )
  62.    /*
  63.    * Steve's code had "Shadow" commented out (didn't include it either)
  64.    * I used a generic shadow udf (see below) so not to add any lib calls
  65.    */
  66.    Shadow( nRow-2, nLcol-2, nRow+1, 81 - nLcol )
  67.  
  68.    @ nRow - 2, nLcol - 2, nRow + 1, 81 - nLcol box "╔═╗║╝═╚║ "
  69.    @ nRow - 1, ( maxcol() / 2 ) - ( len( cText ) / 2 ) say cText
  70.    nOffSet := ( maxcol() / 2 + 1 ) - ( nArrayLen + ( nSpace * ( len( aPicks ) + 1 ) ) ) / 2
  71.    @ nRow, nOffSet say ""
  72.    nLen := len( aPicks )
  73.  
  74.    FOR i = 1 TO nLen
  75.       @ nRow, COL() + nSpace prompt aPicks[i]
  76.    next
  77.  
  78.    menu to nWhich
  79.    setcolor( cColor )
  80.    restscreen( nRow - 3, 0, nRow + 3, maxcol(), cScrn )
  81. return nWhich
  82. /*
  83. * What it does: places a shadow around boxes
  84. */
  85. Procedure Shadow( nTr, nTc, nBr, nBc,nColor )
  86.     DEFAULT nColor TO 7
  87.     MakeShad( nBr+1, nTc+1, nBr+1, nBc+1,nColor )
  88.     MakeShad( nTr+1, nBc+1, nBr+1, nBc+1,nColor )
  89. Return
  90. STATIC Procedure MakeShad( nTr, nTc, nBr, nBc,nColor )
  91.     local cStrip:= SAVESCREEN( nTr, nTc, nBr, nBc )
  92.     local cTemp := REPLICATE( 'x' +chr(nColor), LEN(cStrip) /2 )
  93.     cStrip      := TRANSFORM( cStrip, cTemp )
  94.     RESTSCREEN( nTr, nTc, nBr, nBc, cStrip )
  95. Return
  96. /*
  97. * Author......: Kevin S. Gallagher
  98. * what it does: shows help at the DOS prompt, called from MAIN()
  99. */
  100. function CMDHELP(Err)
  101.     local Drv:=""
  102.     if VALTYPE(Err) == "C"
  103.         /*
  104.         * gotta error from the errorsystem
  105.         */
  106.         alert("READ;ERROR.TXT;FOR LIST OF ERRORS",{" QUIT "})
  107.         QUIT
  108.     endif
  109.     setcolor("w/n")
  110.     scroll(0,0,14,80,14)
  111.     Drv := SUBS(curdrive(),1,2)
  112.     @0,0 say PADR("VTREE  by Kevin S. Gallagher",80) color "n/bg"
  113.     DevPos(1,0);DevOut("VTREE ","GR+");DevOut("[","RB+")
  114.     DevOut("drive","W+");DevOut("]","RB+");DevOut(" [","RB+")
  115.     DevOut("/R","W+");DevOut("] [","RB+");DevOut("/W","W+");DevOut("]","RB+")
  116.  
  117.     @ 2,0 say "[drive]  --> drive to read" 
  118.     @ 3,0 say "[/R]     --> re-read disk file"
  119.     @ 4,0 say "[/W]     --> write disk file"
  120.     @ 5,0 say "[/?]     --> this screen"
  121.     @ 6,0 say "Example: Read current log drive "+Drv+" w/o written disk file"
  122.     @ 7,0 say "VTREE [enter]"
  123.     @ 8,0 say "Read drive H: and write disk array"
  124.     @ 9,0 say "VTREE H: /W [enter]"
  125.  
  126.     @11,0 say "VTREE's disk file also works with my file finder utility"
  127.     @14,0
  128.     quit
  129. return nil
  130. /*
  131. * Author......: Kevin S. Gallagher 
  132. * What it does: get the current logged drive 
  133. */
  134. function curdrive
  135.     local nHandle:=0,cBuf:=space(20),cDrv:=""
  136.     run cd >$$$$$$$$.000
  137.     if file("$$$$$$$$.000")
  138.         nHandle:=fopen("$$$$$$$$.000",0)
  139.         if ferror() = 0
  140.             fread(nHandle,@cBuf,20)
  141.             fclose(nHandle)
  142.             ferase("$$$$$$$$.000")
  143.             cDrv:=if("\" $ subs(cBuf,3,1),subs(cBuf,1,3),subs(cBuf,1,2)+"\")
  144.             /*
  145.             * uncomment for full path
  146.             * cdrv += curdir()
  147.             */
  148.         endif
  149.     endif
  150.     cdrv:=upper(cdrv)
  151. return cdrv
  152.  
  153. #ifdef NEEDME
  154. /*
  155. * inkey as a wait state
  156. */
  157. function WKEY(nDelay)
  158.     local nKey, cblock
  159.     DO CASE
  160.         CASE pcount() == 0
  161.             nKey := inkey()
  162.         CASE nDelay == NIL .AND. Pcount() == 1
  163.             nKey := inkey(0)
  164.         OTHERWISE
  165.             nKey := inkey(nDelay)
  166.     ENDCASE
  167.  
  168.     cblock := setkey(nKey)
  169.     IF cblock != NIL
  170.         eval(cblock, Procname(1), Procline(1), NIL)
  171.     ENDIF
  172. RETURN nKey
  173. #endif
  174.  
  175. function DrvReady( cDrv )
  176.     local nHandle := fopen( cDrv+":\NUL:")
  177. return ( ferror() <> 3 )
  178.  
  179.  
  180.  
  181.